package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlKeyway;
import com.ruoyi.hualian.service.IHlKeywayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 键槽Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/keyway")
public class HlKeywayController extends BaseController
{
    @Autowired
    private IHlKeywayService hlKeywayService;

    /**
     * 查询键槽列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:keyway:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlKeyway hlKeyway)
    {
        startPage();
        List<HlKeyway> list = hlKeywayService.selectHlKeywayList(hlKeyway);
        return getDataTable(list);
    }

    /**
     * 导出键槽列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:keyway:export')")
    @Log(title = "键槽", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlKeyway hlKeyway)
    {
        List<HlKeyway> list = hlKeywayService.selectHlKeywayList(hlKeyway);
        ExcelUtil<HlKeyway> util = new ExcelUtil<HlKeyway>(HlKeyway.class);
        util.exportExcel(response, list, "键槽数据");
    }

    /**
     * 获取键槽详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:keyway:query')")
    @GetMapping(value = "/{keywayId}")
    public AjaxResult getInfo(@PathVariable("keywayId") Long keywayId)
    {
        return success(hlKeywayService.selectHlKeywayByKeywayId(keywayId));
    }

    /**
     * 新增键槽
     */
    @PreAuthorize("@ss.hasPermi('hualian:keyway:add')")
    @Log(title = "键槽", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlKeyway hlKeyway)
    {
        return toAjax(hlKeywayService.insertHlKeyway(hlKeyway));
    }

    /**
     * 修改键槽
     */
    @PreAuthorize("@ss.hasPermi('hualian:keyway:edit')")
    @Log(title = "键槽", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlKeyway hlKeyway)
    {
        return toAjax(hlKeywayService.updateHlKeyway(hlKeyway));
    }

    /**
     * 删除键槽
     */
    @PreAuthorize("@ss.hasPermi('hualian:keyway:remove')")
    @Log(title = "键槽", businessType = BusinessType.DELETE)
	@DeleteMapping("/{keywayIds}")
    public AjaxResult remove(@PathVariable Long[] keywayIds)
    {
        return toAjax(hlKeywayService.deleteHlKeywayByKeywayIds(keywayIds));
    }
}
